﻿using DL.FSM;

namespace DL.Characters.Player.FSM.State
{
    public class PlayerState : IState
    {
        public int priority { protected set;get; } = 0;
        public string name { get => this.GetType().Name; }
        
        protected PlayerState(int priority = 0)
        {
            this.priority = priority;
        }
        
        public virtual void Enter()
        {
            // Debug.Log("Enter State:" + name);
            AddInputActionCallBacks();
        }

        public virtual bool StateTransitionCheck()
        {
            return false;
        }

        public virtual void StateTransitionCompleted()
        {
        }

        public virtual void Exit()
        {
            RemoveInputActionCallBacks();
        }

        public virtual void HandleInput()
        {
        }

        public virtual void FixedUpdate()
        {
        }

        public virtual void Update()
        {
        }

        public virtual void OnAnimationMove()
        {
        }

        public virtual void OnAnimationTranslateEvent<T>() where T : IState
        {
        }

        public virtual void OnAnimationExitEvent()
        {
        }
        
        /// <summary>
        /// InputAction回调添加
        /// 该状态下可以存在行为回调注册
        /// </summary>
        protected virtual void AddInputActionCallBacks() { }

        /// <summary>
        /// InputAction回调移除
        /// 该状态下退出移除行为回调注册
        /// </summary>
        protected virtual void RemoveInputActionCallBacks() { }
    }
}